home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15236 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  2.3 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 6e 65 | 77 73 32 2e 69 6f 73 2e |Path: ne|ws2.ios.|
|00000010| 63 6f 6d 21 75 73 65 6e | 65 74 0a 46 72 6f 6d 3a |com!usen|et.From:|
|00000020| 20 4b 65 69 74 68 20 42 | 6f 72 75 66 66 20 3c 6b | Keith B|oruff <k|
|00000030| 62 6f 72 75 66 66 40 76 | 69 6c 6c 61 67 65 2e 69 |boruff@v|illage.i|
|00000040| 6f 73 2e 63 6f 6d 3e 0a | 4e 65 77 73 67 72 6f 75 |os.com>.|Newsgrou|
|00000050| 70 73 3a 20 63 6f 6d 70 | 2e 6c 61 6e 67 2e 63 2b |ps: comp|.lang.c+|
|00000060| 2b 0a 53 75 62 6a 65 63 | 74 3a 20 52 65 3a 20 61 |+.Subjec|t: Re: a|
|00000070| 6e 6f 74 68 65 72 20 6f | 76 65 72 6c 6f 61 64 69 |nother o|verloadi|
|00000080| 6e 67 20 71 75 65 73 74 | 69 6f 6e 0a 44 61 74 65 |ng quest|ion.Date|
|00000090| 3a 20 54 68 75 2c 20 30 | 34 20 41 70 72 20 31 39 |: Thu, 0|4 Apr 19|
|000000a0| 39 36 20 30 34 3a 35 30 | 3a 30 31 20 2d 30 38 30 |96 04:50|:01 -080|
|000000b0| 30 0a 4f 72 67 61 6e 69 | 7a 61 74 69 6f 6e 3a 20 |0.Organi|zation: |
|000000c0| 49 6e 74 65 72 6e 65 74 | 20 4f 6e 6c 69 6e 65 20 |Internet| Online |
|000000d0| 53 65 72 76 69 63 65 73 | 0a 4d 65 73 73 61 67 65 |Services|.Message|
|000000e0| 2d 49 44 3a 20 3c 33 31 | 36 33 43 35 37 39 2e 36 |-ID: <31|63C579.6|
|000000f0| 41 42 35 40 76 69 6c 6c | 61 67 65 2e 69 6f 73 2e |AB5@vill|age.ios.|
|00000100| 63 6f 6d 3e 0a 52 65 66 | 65 72 65 6e 63 65 73 3a |com>.Ref|erences:|
|00000110| 20 3c 34 6a 75 39 38 64 | 24 33 61 6c 40 70 61 6e | <4ju98d|$3al@pan|
|00000120| 6f 72 61 6d 69 78 2e 66 | 69 2e 75 70 6d 2e 65 73 |oramix.f|i.upm.es|
|00000130| 3e 0a 4e 4e 54 50 2d 50 | 6f 73 74 69 6e 67 2d 48 |>.NNTP-P|osting-H|
|00000140| 6f 73 74 3a 20 70 70 70 | 2d 33 2e 74 73 2d 33 2e |ost: ppp|-3.ts-3.|
|00000150| 6e 79 63 2e 69 64 74 2e | 6e 65 74 0a 4d 69 6d 65 |nyc.idt.|net.Mime|
|00000160| 2d 56 65 72 73 69 6f 6e | 3a 20 31 2e 30 0a 43 6f |-Version|: 1.0.Co|
|00000170| 6e 74 65 6e 74 2d 54 79 | 70 65 3a 20 74 65 78 74 |ntent-Ty|pe: text|
|00000180| 2f 70 6c 61 69 6e 3b 20 | 63 68 61 72 73 65 74 3d |/plain; |charset=|
|00000190| 75 73 2d 61 73 63 69 69 | 0a 43 6f 6e 74 65 6e 74 |us-ascii|.Content|
|000001a0| 2d 54 72 61 6e 73 66 65 | 72 2d 45 6e 63 6f 64 69 |-Transfe|r-Encodi|
|000001b0| 6e 67 3a 20 37 62 69 74 | 0a 58 2d 4d 61 69 6c 65 |ng: 7bit|.X-Maile|
|000001c0| 72 3a 20 4d 6f 7a 69 6c | 6c 61 20 32 2e 30 20 28 |r: Mozil|la 2.0 (|
|000001d0| 57 69 6e 31 36 3b 20 49 | 29 0a 54 6f 3a 20 53 61 |Win16; I|).To: Sa|
|000001e0| 63 68 61 20 3c 73 61 63 | 68 61 40 64 69 61 66 69 |cha <sac|ha@diafi|
|000001f0| 2e 75 70 6d 2e 65 73 3e | 0a 0a 53 61 63 68 61 20 |.upm.es>|..Sacha |
|00000200| 77 72 6f 74 65 3a 0a 3e | 20 0a 3e 20 48 69 2c 0a |wrote:.>| .> Hi,.|
|00000210| 3e 20 0a 3e 20 43 61 6e | 20 49 20 6f 76 65 72 6c |> .> Can| I overl|
|00000220| 6f 61 64 20 3d 20 66 6f | 72 20 73 69 6d 70 6c 65 |oad = fo|r simple|
|00000230| 20 74 79 70 65 73 3f 0a | 3e 20 0a 3e 20 49 20 6d | types?.|> .> I m|
|00000240| 65 61 6e 2c 20 69 66 20 | 66 6f 72 20 65 78 61 6d |ean, if |for exam|
|00000250| 70 6c 65 20 49 20 68 61 | 76 65 3a 0a 3e 20 0a 3e |ple I ha|ve:.> .>|
|00000260| 20 20 20 20 20 20 20 20 | 20 63 6c 61 73 73 20 43 | | class C|
|00000270| 6f 6c 6f 75 72 0a 3e 20 | 20 20 20 20 20 20 20 20 |olour.> | |
|00000280| 7b 0a 3e 20 20 20 20 20 | 20 20 20 20 70 72 69 76 |{.> | priv|
|00000290| 61 74 65 3a 0a 3e 20 20 | 20 20 20 20 20 20 20 20 |ate:.> | |
|000002a0| 20 66 6c 6f 61 74 20 72 | 5f 2c 20 67 5f 2c 20 62 | float r|_, g_, b|
|000002b0| 5f 3b 0a 3e 20 0a 3e 20 | 20 20 20 20 20 20 20 20 |_;.> .> | |
|000002c0| 70 75 62 6c 69 63 3a 0a | 3e 20 20 20 20 20 20 20 |public:.|> |
|000002d0| 20 20 20 20 43 6f 6c 6f | 75 72 28 66 6c 6f 61 74 | Colo|ur(float|
|000002e0| 20 72 2c 20 66 6c 6f 61 | 74 20 67 2c 20 66 6c 6f | r, floa|t g, flo|
|000002f0| 61 74 20 62 29 0a 3e 20 | 20 20 20 20 20 20 20 20 |at b).> | |
|00000300| 20 20 20 20 20 20 20 20 | 7b 72 5f 3d 72 3b 20 67 | |{r_=r; g|
|00000310| 5f 3d 67 3b 20 62 5f 3d | 62 3b 7d 0a 3e 20 20 20 |_=g; b_=|b;}.> |
|00000320| 20 20 20 20 20 20 7d 3b | 0a 3e 20 0a 3e 20 69 73 | };|.> .> is|
|00000330| 20 74 68 65 72 65 20 73 | 6f 6d 65 20 77 61 79 20 | there s|ome way |
|00000340| 49 20 63 61 6e 20 6f 76 | 65 72 6c 6f 61 64 20 3d |I can ov|erload =|
|00000350| 20 73 6f 20 74 68 61 74 | 20 49 20 63 61 6e 20 64 | so that| I can d|
|00000360| 6f 20 74 68 69 6e 67 73 | 20 6c 69 6b 65 3a 0a 3e |o things| like:.>|
|00000370| 20 0a 3e 20 20 20 20 20 | 20 20 20 20 43 6f 6c 6f | .> | Colo|
|00000380| 75 72 20 63 6f 6c 6f 75 | 72 28 30 2e 39 39 32 33 |ur colou|r(0.9923|
|00000390| 38 2c 20 30 2e 31 37 32 | 33 36 34 2c 20 30 2e 32 |8, 0.172|364, 0.2|
|000003a0| 37 33 29 3b 0a 3e 20 0a | 3e 20 20 20 20 20 20 20 |73);.> .|> |
|000003b0| 20 20 69 6e 74 20 69 6e | 74 65 6e 73 69 74 79 20 | int in|tensity |
|000003c0| 3d 20 63 6f 6c 6f 75 72 | 3b 0a 3e 20 0a 3e 20 73 |= colour|;.> .> s|
|000003d0| 75 63 68 20 74 68 61 74 | 20 69 6e 74 65 6e 73 69 |uch that| intensi|
|000003e0| 74 79 20 69 73 20 61 73 | 73 69 67 6e 65 64 20 61 |ty is as|signed a|
|000003f0| 20 76 61 6c 75 65 20 63 | 6f 6d 70 75 74 65 64 20 | value c|omputed |
|00000400| 66 72 6f 6d 20 72 2c 67 | 2c 62 20 28 65 2e 67 2e |from r,g|,b (e.g.|
|00000410| 20 74 68 65 20 61 76 65 | 72 61 67 65 29 3f 0a 0a | the ave|rage)?..|
|00000420| 53 61 73 68 61 2c 20 0a | 0a 49 74 20 6d 61 79 20 |Sasha, .|.It may |
|00000430| 62 65 20 62 65 74 74 65 | 72 20 69 66 20 79 6f 75 |be bette|r if you|
|00000440| 20 63 72 65 61 74 65 20 | 61 20 6d 65 6d 62 65 72 | create |a member|
|00000450| 20 66 75 6e 63 74 69 6f | 6e 20 63 61 6c 6c 65 64 | functio|n called|
|00000460| 20 69 6e 74 65 6e 73 69 | 74 79 20 69 6e 73 74 65 | intensi|ty inste|
|00000470| 61 64 20 6f 66 20 74 72 | 79 69 6e 67 20 74 6f 20 |ad of tr|ying to |
|00000480| 0a 6f 76 65 72 6c 6f 61 | 64 20 74 68 65 20 22 3d |.overloa|d the "=|
|00000490| 22 20 6f 70 65 72 61 74 | 6f 72 2e 20 22 3d 22 20 |" operat|or. "=" |
|000004a0| 69 73 20 61 6c 72 65 61 | 64 79 20 73 65 74 20 75 |is alrea|dy set u|
|000004b0| 70 20 61 73 20 61 20 6d | 65 6d 62 65 72 77 69 73 |p as a m|emberwis|
|000004c0| 65 20 64 65 66 61 75 6c | 74 20 6f 70 65 72 61 74 |e defaul|t operat|
|000004d0| 6f 72 20 77 68 69 63 68 | 20 0a 6d 65 61 6e 73 3a |or which| .means:|
|000004e0| 0a 0a 43 6f 6c 6f 75 72 | 20 4f 62 6a 65 63 74 41 |..Colour| ObjectA|
|000004f0| 2c 20 4f 62 6a 65 63 74 | 42 3b 0a 4f 62 6a 65 63 |, Object|B;.Objec|
|00000500| 74 41 20 3d 20 4f 62 6a | 65 63 74 42 20 2f 2f 20 |tA = Obj|ectB // |
|00000510| 59 6f 75 20 63 61 6e 20 | 61 73 73 69 67 6e 20 6f |You can |assign o|
|00000520| 62 6a 65 63 74 73 20 77 | 69 74 68 6f 75 74 20 63 |bjects w|ithout c|
|00000530| 72 65 61 74 69 6e 67 20 | 61 6e 20 22 3d 22 20 6f |reating |an "=" o|
|00000540| 70 65 72 61 74 6f 72 20 | 66 75 6e 63 74 69 6f 6e |perator |function|
|00000550| 2e 0a 0a 4e 6f 77 20 62 | 61 63 6b 20 74 6f 20 6f |...Now b|ack to o|
|00000560| 75 72 20 6d 65 6d 62 65 | 72 20 66 75 6e 63 74 69 |ur membe|r functi|
|00000570| 6f 6e 20 63 61 6c 6c 65 | 64 20 22 69 6e 74 65 6e |on calle|d "inten|
|00000580| 73 69 74 79 22 2e 20 59 | 6f 75 20 77 61 6e 74 20 |sity". Y|ou want |
|00000590| 74 6f 20 63 72 65 61 74 | 65 20 73 6f 6d 65 74 68 |to creat|e someth|
|000005a0| 69 6e 67 20 77 68 69 63 | 68 20 0a 72 65 74 75 72 |ing whic|h .retur|
|000005b0| 6e 73 20 61 6e 20 61 76 | 65 72 61 67 65 20 6f 66 |ns an av|erage of|
|000005c0| 20 74 68 72 65 65 20 6e | 75 6d 62 65 72 73 2e 20 | three n|umbers. |
|000005d0| 59 6f 75 72 20 73 74 61 | 74 65 6d 65 6e 74 20 22 |Your sta|tement "|
|000005e0| 69 6e 74 20 69 6e 74 65 | 6e 73 69 74 79 20 3d 20 |int inte|nsity = |
|000005f0| 63 6f 6c 6f 75 72 22 20 | 63 6f 6e 66 75 73 65 73 |colour" |confuses|
|00000600| 20 6d 65 20 0a 62 65 63 | 61 75 73 65 20 77 69 74 | me .bec|ause wit|
|00000610| 68 20 74 68 65 20 72 65 | 61 6c 20 6e 75 6d 62 65 |h the re|al numbe|
|00000620| 72 73 20 74 68 61 74 20 | 79 6f 75 20 75 73 65 2c |rs that |you use,|
|00000630| 20 79 6f 75 72 20 66 69 | 6e 61 6c 20 61 76 65 72 | your fi|nal aver|
|00000640| 61 67 65 20 76 61 6c 75 | 65 20 77 69 6c 6c 20 62 |age valu|e will b|
|00000650| 65 20 74 72 75 6e 63 61 | 74 65 64 20 74 6f 20 0a |e trunca|ted to .|
|00000660| 7a 65 72 6f 2e 20 54 72 | 79 20 74 68 69 73 20 69 |zero. Tr|y this i|
|00000670| 6e 73 74 65 61 64 3a 0a | 0a 2f 2f 20 6d 65 6d 62 |nstead:.|.// memb|
|00000680| 65 72 20 66 75 6e 63 74 | 69 6f 6e 20 64 65 63 6c |er funct|ion decl|
|00000690| 61 72 61 74 69 6f 6e 20 | 2d 3e 20 70 75 62 6c 69 |aration |-> publi|
|000006a0| 63 20 77 69 74 68 69 6e | 20 43 6f 6c 6f 75 72 20 |c within| Colour |
|000006b0| 63 6c 61 73 73 3a 0a 66 | 6c 6f 61 74 20 69 6e 74 |class:.f|loat int|
|000006c0| 65 6e 73 69 74 79 28 76 | 6f 69 64 29 3b 0a 0a 0a |ensity(v|oid);...|
|000006d0| 2f 2f 44 65 66 69 6e 69 | 74 69 6f 6e 20 2d 3e 20 |//Defini|tion -> |
|000006e0| 61 73 73 75 6d 65 64 20 | 74 6f 20 62 65 20 64 65 |assumed |to be de|
|000006f0| 66 69 6e 65 64 20 6f 75 | 74 73 69 64 65 20 6f 66 |fined ou|tside of|
|00000700| 20 63 6c 61 73 73 20 28 | 6e 6f 74 20 69 6e 6c 69 | class (|not inli|
|00000710| 6e 65 64 29 0a 66 6c 6f | 61 74 20 43 6f 6c 6f 75 |ned).flo|at Colou|
|00000720| 72 3a 3a 69 6e 74 65 6e | 73 69 74 79 28 76 6f 69 |r::inten|sity(voi|
|00000730| 64 29 0a 7b 0a 09 72 65 | 74 75 72 6e 20 28 28 72 |d).{..re|turn ((r|
|00000740| 5f 20 2b 20 67 5f 20 2b | 20 62 5f 29 20 2f 20 33 |_ + g_ +| b_) / 3|
|00000750| 2e 30 29 3b 0a 7d 0a 0a | 0a 57 69 74 68 69 6e 20 |.0);.}..|.Within |
|00000760| 61 6e 79 20 70 72 6f 67 | 72 61 6d 20 79 6f 75 20 |any prog|ram you |
|00000770| 75 73 65 20 74 68 65 20 | 63 6c 61 73 73 20 22 43 |use the |class "C|
|00000780| 6f 6c 6f 75 72 22 20 69 | 6e 2c 20 79 6f 75 20 63 |olour" i|n, you c|
|00000790| 6f 75 6c 64 20 75 73 65 | 20 74 68 69 73 20 66 75 |ould use| this fu|
|000007a0| 6e 63 74 69 6f 6e 20 66 | 6f 72 20 61 20 0a 43 6f |nction f|or a .Co|
|000007b0| 6c 6f 75 72 20 6f 62 6a | 65 63 74 20 61 73 20 73 |lour obj|ect as s|
|000007c0| 75 63 68 3a 0a 0a 09 66 | 6c 6f 61 74 0a 09 09 49 |uch:...f|loat...I|
|000007d0| 6e 74 65 6e 73 69 74 79 | 56 61 6c 75 65 20 3d 20 |ntensity|Value = |
|000007e0| 43 6f 6c 6f 75 72 4f 62 | 6a 65 63 74 2e 69 6e 74 |ColourOb|ject.int|
|000007f0| 65 6e 73 69 74 79 28 29 | 3b 0a 0a 4f 6e 65 20 6f |ensity()|;..One o|
|00000800| 74 68 65 72 20 74 68 69 | 6e 67 2c 20 62 65 63 61 |ther thi|ng, beca|
|00000810| 75 73 65 20 79 6f 75 20 | 61 72 65 6e 27 74 20 61 |use you |aren't a|
|00000820| 6c 74 65 72 69 6e 67 20 | 74 68 65 20 64 61 74 61 |ltering |the data|
|00000830| 20 6d 65 6d 62 65 72 20 | 76 61 6c 75 65 73 2c 20 | member |values, |
|00000840| 79 6f 75 20 63 6f 75 6c | 64 20 61 74 74 61 63 68 |you coul|d attach|
|00000850| 20 61 20 0a 22 63 6f 6e | 73 74 22 20 74 6f 20 74 | a ."con|st" to t|
|00000860| 68 65 20 65 6e 64 73 20 | 6f 66 20 74 68 65 20 22 |he ends |of the "|
|00000870| 69 6e 74 65 6e 73 69 74 | 79 22 20 64 65 63 6c 61 |intensit|y" decla|
|00000880| 72 61 74 69 6f 6e 20 61 | 6e 64 20 64 65 66 69 6e |ration a|nd defin|
|00000890| 69 74 69 6f 6e 20 66 75 | 6e 63 74 69 6f 6e 20 68 |ition fu|nction h|
|000008a0| 65 61 64 65 72 73 20 73 | 6f 20 0a 74 68 61 74 20 |eaders s|o .that |
|000008b0| 79 6f 75 20 63 61 6e 20 | 75 73 65 20 61 6e 79 20 |you can |use any |
|000008c0| 22 63 6f 6e 73 74 22 20 | 64 65 63 6c 61 72 65 64 |"const" |declared|
|000008d0| 20 6f 62 6a 65 63 74 73 | 2e 0a 0a 48 6f 70 65 20 | objects|...Hope |
|000008e0| 74 68 69 73 20 68 65 6c | 70 73 2c 0a 4b 65 69 74 |this hel|ps,.Keit|
|000008f0| 68 20 42 6f 72 75 66 66 | 0a 4c 6f 6e 67 20 49 73 |h Boruff|.Long Is|
|00000900| 6c 61 6e 64 2c 20 4e 59 | 0a |land, NY|. |
+--------+-------------------------+-------------------------+--------+--------+